package com.shaoshaohuo.app.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.shaoshaohuo.app.R;
import com.shaoshaohuo.app.entity.Newshaopfcationentity;

import java.util.List;

/**
 * Created by Administrator on 2017/6/5.
 */

public class FragmentFicationadapter extends MyBaseAdapter<Newshaopfcationentity.DataBean> {

    private final LayoutInflater from;

    public FragmentFicationadapter(Context ctx, List<Newshaopfcationentity.DataBean> list, boolean flag) {
        super(ctx, list, flag);
        from = LayoutInflater.from(ctx);
    }

    @Override
    public View getView(int pos, View view, ViewGroup group) {
        MyHolder myHolder;
        if (view == null) {
            myHolder = new MyHolder();
            View inflate = from.inflate(R.layout.fragmentshopfication, group, false);
            view = inflate;
            myHolder.imageView = (ImageView) view.findViewById(R.id.shopfication_ivsele);
            myHolder.textView = (TextView) view.findViewById(R.id.shopfication_tvsele);
            view.setTag(myHolder);
        } else {
            myHolder = (MyHolder) view.getTag();
        }
        Newshaopfcationentity.DataBean newshaopfcationentity = list.get(pos);
        boolean isdow = newshaopfcationentity.isdow();
        if (isdow) {
            myHolder.imageView.setVisibility(View.VISIBLE);
            myHolder.textView.setTextColor(Color.parseColor("#496152"));
            view.setBackgroundColor(Color.WHITE);
        } else {
            myHolder.imageView.setVisibility(View.GONE);
            myHolder.textView.setTextColor(Color.parseColor("#666666"));
            view.setBackgroundColor(Color.parseColor("#f4f4f4"));
        }
        String shopname = list.get(pos).getName();
        myHolder.textView.setText(shopname);
        return super.getView(pos, view, group);
    }


    class MyHolder {
        TextView textView;
        ImageView imageView;
    }
}
